/******************************************************************************************
 * Import
 ******************************************************************************************/
import _ from 'lodash';
import React, {Component} from 'react';
import Design from '../../../../design';
import Config from '../../../../config';
import ScreenBase from '../../../../library/base/screen';
// import SplashScreen from 'react-native-splash-screen';
import {
    CAround, CBetween, CCenter, CColumn, CHand, CItemX, CItemY, CLine, CRow, CWrap, 
    CIcon, CImage, CSvg, CText,
    CContent, CFloat, CFooter, CHeader, CPage, CSide, 
    CEmpty, CError, CFail, CSkeleton, 
    CLabel, CButton
} from '../../../../library/comp';
import {
    HttpText, HttpHesq
} from '../../../../library/func';

// svg
import Licon from '../../../../library/comp/project/icon';


/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class ProductList extends Component {

	/*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
		super(props);

		/**
		 * state
		 */
		this.state = {
			
		}
	}

	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/
	render () {
		return (
			<CColumn ma='20'>
				{this.props.data.map((item,index) => {
					let name = item.object.set_order_name
					if(name.length > 28){
						name = name.substr(0, 28) + '...'
					}
					return (
						<CColumn bg='#fff' mb='20' ra='20'>
							{/* 店铺名称 */}
							<CBetween pr='20' >
								<CLine px='20' py='30'>
									<CIcon icon={ Licon["shop-stroew"] } color='#6d6d6d' w='26' h='28'></CIcon>
									<CText size='24' pl='16'>每日一达</CText>
								</CLine>
								<CText size='24' color='#df3641'>{item.enum_status}</CText>
							</CBetween>

							{/* 商品信息 */}
							<CLine bg='#f9f9f9' pa='16' y='center' bb='2 #f6f6f6' >
								{/* <CImage src='https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1542628687189&di=5022ae04443483dd4ebe42484ecfc2c3&imgtype=0&src=http%3A%2F%2Fm.tuniucdn.com%2Ffb2%2Ft1%2FG1%2FM00%2FA7%2F22%2FCii-U1jI-3GIHWSoAAY3TTlDHnoAAI4BQP3s40ABjdl776_w640_h480_c1_t0.jpg'/> */}
								<CImage
									style={{width: 65, height: 65}}
									source={{uri:'http://image.cdn.hesq.com.cn/rushbuy/product/20181114/1542164973540zpkr.jpg'}}
								/>
								<CColumn pl='20'>
									<CBetween y='top' df>
										<CText size='23' color='#252525' f='1'>{name}</CText>
										<CText size='28' pl='10' pr='10' df color='#252525'>￥{item.set_amount}</CText>
									</CBetween>
									<CLine pt='10' pr='10' x='right' style={{width:'100%'}}>
										<CText size='25' color='#aaa'>x{item.count_product}</CText>
									</CLine>
								</CColumn>
							</CLine>

							{/* 订单信息底部部分 */}
							<CLine px='30' pt='20' x='right' style={{width:'100%'}}>
								<CText size='24'>共计 {item.count_product} 件商品&nbsp;&nbsp;&nbsp;实付:</CText>
								<CText size='30' color='#cc2d2e' bold>￥{item.set_amount}</CText>
							</CLine>

							{/* 按钮 */}
							<CLine pa='20' x='right' style={{width:'100%'}}>
								{/* 已完成显示 */}
								{item.enum_status == '已完成' && 
									<CButton ba='2 #cb2829' bg='#cb2829' ml='20' ra='100' py='5' px='18'><CText style={{fontSize:12}} color='#fff'>评论订单</CText></CButton>
								}

								{/* 已发货显示 */}
								{item.enum_status == '已发货' && 
									<CButton ba='2 #cb2829' bg='#cb2829' ml='20' ra='100' py='5' px='18'><CText style={{fontSize:12}} color='#fff'>确认收货</CText></CButton>	
								}

								{/* 未付款显示 */}
								{item.enum_status == '未付款' && 
									<CHand>
										<CButton ba='2 #cb2829' ra='100' py='5' px='18' ><CText style={{fontSize:12}} color='#cb2829'>取消订单</CText></CButton>
										<CButton ba='2 #cb2829' bg='#cb2829' ml='20' ra='100' py='5' px='45'><CText style={{fontSize:12}} color='#fff'>付款</CText></CButton>
									</CHand>
								}

								{/* 未发货显示 */}
								{item.enum_status == '未发货' && 
									<CHand>
										<CButton ba='2 #cb2829' bg='#cb2829' ra='100' py='5' px='18 '><CText style={{fontSize:12}} color='#fff'>查看订单</CText></CButton>
									</CHand>
								}

								{/* 已取消显示 */}
								{item.enum_status == '已取消' && 
									<CHand>
										<CButton ba='2 #cb2829' bg='#cb2829' ra='100' py='5' px='18'><CText style={{fontSize:12}} color='#fff'>查看订单</CText></CButton>
									</CHand>
								}
							</CLine>

						</CColumn>
					)
				})}
            </CColumn>
		)
	}
}


